import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/LoginView.vue'
import error from '../views/ErrorView.vue'
import home from '../views/HomeView.vue'
import about from '../views/AboutView.vue'
import menu from '../views/MenuView.vue'
import role from '../views/RoleView.vue'
import order from '../views/OrderView.vue'
import person from '../views/PersonView.vue'
import user from '../views/UserView.vue'

Vue.use(VueRouter)

// 前端路由
export const dynamicRrouter = [
  {
    path: '/order',
    name: 'order',
    meta: {
      title: '商品管理'
    },
    component: order
  },
  {
    path: '/person',
    name: 'person',
    meta: {
      title: '个人中心'
    },
    component: person
  },
  {
    path: '/user',
    name: 'user',
    meta: {
      title: '用户管理'
    },
    component: user
  },
  {
    path: '/role',
    name: 'role',
    meta: {
      title: '角色管理'
    },
    component: role
  },
  {
    path: '/menu',
    name: 'menu',
    meta: {
      title: '菜单管理'
    },
    component: menu
  }
]

// 基础路由
export const baseRoutes = [
  {
    path: '/about',
    meta: {
      title: '主页',
      isLogin: true
    },
    component: about,
    redirect: '/home',
    children: [
      {
        path: '/home',
        meta: {
          title: '首页'
        },
        component: home
      }]
  },
  {
    path: '/errorView',
    meta: {
      title: '404'
    },
    component: error
  },
  {
    path: '/login',
    meta: {
      title: '登陆'
    },
    component: login
  }
]

export default new VueRouter({
  // mode: 'history',
  routes: baseRoutes
})
